package com.example.battle.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.battle.R;
import com.example.battle.entity.FansName;
import com.example.battle.util.ActivityCollector;
import com.example.battle.widget.TitleLayout;
import com.google.android.material.snackbar.Snackbar;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class FansNameDetailActivity extends AppCompatActivity {
    private TextView fansname,starname,registerDate,status,weburl;
    private TitleLayout titleLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fans_name_detail);

        fansname = findViewById(R.id.fansname_detail_fansname);
        starname = findViewById(R.id.fansname_detail_starname);
//        registerDate = findViewById(R.id.fansname_detail_registerdate);
        status = findViewById(R.id.fansname_detail_status);
        weburl = findViewById(R.id.fansname_detail_weburl);
        titleLayout = findViewById(R.id.fansname_detail_title);
        final Intent intent = getIntent();
        final FansName fansName = (FansName) intent.getSerializableExtra("fansName");
        titleLayout.setTv_title("粉丝名详情");
        titleLayout.getTextView_forward().setText("");
        fansname.setText(fansName.getFansName());
//        咋获取不到明星名字
        starname.setText(fansName.getStarName());
//        Date date = null;
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年mm月dd日 HH:MM:SS");
//        try {
//            date = new SimpleDateFormat().parse(fansName.getRegisterDate());
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        registerDate.setText(sdf.format(date));
        switch (fansName.getStatus()){
            case 0:
                status.setText("已注册");
                break;
            case 1:
                status.setText("待审核");
                break;
            default:
                break;
        }

        weburl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Snackbar.make(v,"是否要打开该网址？",Snackbar.LENGTH_LONG)
                        .setAction("是", new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent1 = new Intent();
                                intent1.setAction(Intent.ACTION_VIEW);
                                intent1.setData(Uri.parse(fansName.getWeburi()));
                                startActivity(intent1);
                            }
                        }).setActionTextColor(Color.parseColor("#D1EEEE")).show();
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityCollector.removeActivity(this);
    }
}
